﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Input;
using System.Windows.Threading;
using Microsoft.Practices.Unity;
using ScrumTable.BL.DM.DataManagement;
using ScrumTable.DL.Data.Common;
using ScrumTable.UI.ViewModel;
using ScrumTable.UI.ViewModel.Controller;
using ScrumTable.UI.ViewModel.Data;
using ScrumTable.UI.ViewModel.Tools;

namespace ScrumTable.UI.View.WinTouch.UserControls.Tool
{
	/// <summary>
	/// Interaction logic for SearchScreen.xaml
	/// </summary>
	public partial class SearchScreen
    {

        #region Decleration
        //--------------------------------------------------------------------
        // Decleration
        //--------------------------------------------------------------------
	    
        #endregion

        #region Properties
        //--------------------------------------------------------------------
        // Properties
        //--------------------------------------------------------------------
   


        [Dependency]
        public ViewModelSearchScreen Model
        {
            set
            {
                TasksListToDo.TheListBox.MultipleColumnsRowsSize = new Size(value.ScrumData.ConfigManager.Config.ControlSize.X,
                                                                       value.ScrumData.ConfigManager.Config.ControlSize.Y);
                DataContext = value;
            }
            get
            {
                return (ViewModelSearchScreen)DataContext;
            }

        }


      
        #endregion

        #region Constructors / Destructor
        //--------------------------------------------------------------------
        // Constructors / Destructor
        //--------------------------------------------------------------------

        public SearchScreen()
        {
            InitializeComponent();
            Loaded += OnLoaded;
        }

       


        #endregion

        #region Methods
        //--------------------------------------------------------------------
        // Methods
        //--------------------------------------------------------------------

       

        #endregion

        #region Events
        //--------------------------------------------------------------------
        // Events
        //--------------------------------------------------------------------

        void OnLoaded(object sender, RoutedEventArgs e)
        {
            Loaded -= OnLoaded;
            TxtSearch.Focus();
        }
      

        private void OnFilterTextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
        {
            Model.FilterText = TxtSearch.Text;
        }


        private void OnSearchClick(object sender, RoutedEventArgs e)
        {
            Model.FilterSettingChanged();
        }

        private void OnSearchKeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                Model.FilterSettingChanged();
            }
        }

        #endregion
    }
}